1. Field of the Invention
This invention relates generally to the management of sharable files, and more particularly to a file consistency protocol that enables the sharing of a file while maintaining consistency in contents between instances of the file.
2. Description of the Related Art
In today""s computing environment computers are increasingly used in a networked environment. As an example, a majority of workplace users are connected to an internal network or system where each user works from a station, such as computer, connected to a server or servers that are part of the network. Each user""s computer contains various applications that operate on files which are stored on the server or on their own station, which may offer analogous services. Therefore, a first user may access the server or analogous device to use a file by way of an application on the first user""s machine. In addition, a second user may also access the same file and use the contents of the file with an application on the second user""s machine. Nonetheless, the situation arises in this shared environment where the first user changes data in the file which is also being used by the second user. As such, file consistency is necessary to ensure that all copies or instances of the file in use contain the same information as updates are performed to each instance of the file.
Currently, the methods available to maintain file consistency among multiple copies of a file include making an independent copy of the file and then manually or explicitly programmatically merging the changes back into the original file; a UNIX type file consistency scheme where an original file is locked after changes are made to a copy; and a distributed file system approach. Each of these prior art techniques will now be discussed in more detail.
As mentioned above, one method of ensuring file consistency requires that an independent copy of the file with a different file name be made. When the user writes changes to with the independent copy, the user must manually integrate the changes made to the independent copy back into the original file, which may be stored on a server. Of course, the changes cannot be merged back into the file while the original copy is in use by another user. As can be appreciated, integrating the changes between files requires significant effort on the part of the users accessing the file, decreases efficiency, and increases the amount of disc space necessary to store the various file copies. Furthermore, when the user makes an independent copy, the independent copy is required to be saved under a different file name (or in a different place, e.g., directory, disk, system, etc). Thus, a subsequent user may not know the new file name or location of the independent copy and may inadvertently access an outdated, invalid copy.
The UNIX operating system also has a method for maintaining file consistency among different copies of files accessible by many users. If multiple copies of a file are being accessed by different users, the UNIX operating system, or applications using the UNIX file system may automatically lock the file so that all users are prevented from saving changes to the file. In order to save changes, the UNIX operating system, file system, or application will also require the user to save the changes to an independent file having a different filename, thereby creating a copy. Thus, a user must wait until all others using the file have closed the file (i.e., making the file no longer shared), or the user must save the file under a different name, which is undesirable for the previously mentioned reasons.
In addition, UNIX allows a user to change the file attributes of the file such that the file is writable by everyone at all times and copies of the file containing different data exist on the UNIX system. As a result, when a file is writable, any modifications made by a first user are independent from other modifications made by a second user. Therefore, the modifications made by the first user do not appear on the copy in use by the second user. By the same token, any modifications made by the second user do not appear on the copy of the file being used by the first user. Thus, all the changes made by individual users are saved to individual copies and are not saved to the original file. Consequently, the original file, and copies of the original file, do not contain the modifications made by both the first and second, etc. users.
As also mentioned, another approach used to facilitate data consistency of a shared file is to use a distributed file system. Under this approach, the distributed file system distributes file data over multiple computers thereby allowing the data to reside at multiple locations simultaneously. With this approach, a user A may have a file A stored on a hard drive of user A""s computer. If a user B wants to access the file on user A""s computer, the distributed file system copies the file A to user B""s memory or hard drive. In this situation, when user B is accessing the file A, a flag is set in the file A which informs the distributed file system that the user B is making changes to the file A. The flag enables the locking of the file A such that when user A attempts to use the file A in a manner that conflicts with user B""s usage (i.e., changing the data in the file A), this setting prevents user A from changing the data. When the user B closes the file A, and the user A attempts to write to the file A, the distributed file system informs the user A that changes have been made and the distributed file system will ask the user A if the user A wants a copy of the file A containing the changes. However, this scheme is inefficient because the distributed file system must track who is modifying the file and the distributed file system must ask individual users, such as user A, when they are trying to access the file A, if the user A wants a fresh copy of the file A containing the changes. Additionally, the inefficiency is further compounded since the distributed file system must provide each user with a new copy in each instance when a separate user attempts access to the file. Furthermore, the distributed file system is not always capable of globally providing a new copy of the file containing the changes to all users which, in some situations, may number hundreds of users. In summary, under the distributed file system approach, the user A and the user B may not simultaneously write to the file A. Instead, if the user A is working with the file A in an exclusive manner, the user B must wait for user A to close the file A before user B may access file A. The file A can still be opened, however, the file will be read-only (i.e., no writing is allowed), and its contents are not guaranteed to be valid/current.
An example of a distributed file system is an Andrew file system. The Andrew file system allows a user to share files over a network and a subsystem. However, the Andrew file system requires an undesirable amount of overhead, such as CPU cycling time and increased network traffic. In addition, overhead is further increased due to the increased amount of user intervention involved with the Andrew file system. The Andrew file system requires user applications to communicate with one another before certain actions, such as data modifications, are commenced. Therefore, as the number of shared users on the network using the Andrew file system increases, the complexity of operating an Andrew file system increases.
Another problem with shared environment platforms where users access files on a shared storage medium relates to file locking and file sharing. An example of the current locking/sharing mechanisms available are a revision control system (RCS) and a source code control system (SCCS). With these approaches, a user C can open a file C in a shared mode and a user D may also access the file C. However, when the file C is opened in the shared mode, neither user may ever modify existing data in the file C or add data to the file C. Therefore, the file C (i.e., while in shared use) becomes a read-only file with the current locking/sharing mechanisms.
As may be seen, none of the prior art techniques previously described enable a real time sharing environment where multiple users may simultaneously read the same file and write to the same file.
In view of the foregoing, there is a need for methods that enable consumers (e.g., users, processors or other entities that control, manipulate or access files) that have access to shareable files to gain access to the files without making independent copies and methods for maintaining consistency in file content of instances of the file.
Broadly speaking, the present invention fills the aforementioned needs by providing methods for maintaining file consistency among instances (i.e., sharable copies) of a file. A file is broadly defined to include, for example, a data file, a disk volume, directory, a special file (e.g., such as a UNIX device node), etc. It should be appreciated that the present invention can be implemented in numerous ways, including as a process, an apparatus, a system, a device, a method, or a computer readable media. Several embodiments of the present invention are described below.
In one embodiment, a method for sharing a file is disclosed. The method includes checking for open instances of the file and determining whether the open instance of the file has a shared bit of a first bitmap set to true. The method further includes opening another instance of the file with a shared bit of a second bitmap of the another instance set to true. In this embodiment, the shared bit of the second bitmap is maintained set to true so long as the open instance of the file or the another instance of the file is open.
In another embodiment, a method for sharing a file managed by a file system is disclosed. The method includes associating a file consistency protocol with an operating system (O/S). The file consistency protocol maintains file consistency between instances of the file associated with the file system using a set of file consistency protocol bits. The method then includes opening an instance of the file in a shared mode by setting a shared bit in the set of file consistency protocol bits associated with the file. A determination is then made as to the existence of another instance of the file. A shared bit the set of file consistency protocol bits associated with the another file is then set. In accordance with the method, a modification is made to the contents (e.g., data or attributes) of the instance of the file. A modified bit is then set in the set of file consistency protocol bits of the instance of the file. The modified bit is indicative of the modified contents, and an invalid bit is set in the set of file consistency protocol bits of the another file. The invalid bit is indicative of the modified contents of the instance of the file.
In yet another embodiment, a method for sharing a file is disclosed. The method includes checking for open instances of the file and determining whether the open instance of the file has a shared bit of a first bitmap set to true. The method further includes opening another instance of the file with a shared bit of a second bitmap of the another instance set to true. In this embodiment, the shared bit of the second bitmap is maintained set to true so long as the open instance of the file or the another instance of the file is open. The method further includes modifying contents of the another file and setting a modified bit in the second bitmap to true. An invalid bit in the first bitmap of open instance of the file is set to true. The invalid bit indicating that the contents of the open instance of the file are not consistent with the contents of the another file due to the modifying.
The advantages of the present invention are numerous. Most notably, embodiments of the present invention enable consistency of file content between shared files (e.g., file instances) being managed by a file system. Thus, when multiple copies of a file are in use and one of the multiple copies are changed, the file consistency protocol ensures that the other multiple copies of the file will also be updated (in accordance with a defined bit map code) when one of the multiple copies is changed. In addition, the present invention allows for an open shared mode to enable multiple users to use (e.g., view, edit, append, concatenate, etc.) copies of the file simultaneously, while at the same time ensuring that consistency is maintained as changes are made by users of instances of the shared file.